import { View } from "../../../../mvc/core/View";
import { Language } from "../../../../../extend/language/Language";
import { ObjCreate } from "../../common/ObjCreate";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { ImagesConst } from "../../../resource/ImagesConst";
import { GuildActivityInfoPanel } from "./GuildActivityInfoPanel";
import { TilePanel } from "../../equipment/TilePanel";
import { GuildActivityCellRenderer } from "./GuildActivityCellRenderer";
import { ListEvent } from "../../../../../fl/events/ListEvent";
import { GuildActivityConfig } from "../../../resource/GuildActivityConfig";
import { GuildActivityConfigInfo } from "../../../resource/info/GuildActivityConfigInfo";
import { DataProvider } from "../../../../../fl/data/DataProvider";
//class GuildActivityListPanel
    
    export  class GuildActivityListPanel extends View
    {
        constructor()
        {
            super();
            this._titleArray = Language.getString(57502).split(",");
            this._titleXArray = [10, 100, 230, 365];
            mouseEnabled = false;
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            var loc1=null;
            ObjCreate.createBg(0, 0, 450, 395, this);
            var loc2=0;
            while (loc2 < this._titleArray.length) 
            {
                loc1 = this._titleArray[loc2] as string;
                ObjCreate.createTextField(loc1, int(this._titleXArray[loc2]), 10, 100, 20, this, GlobalStyle.textFormat2);
                ++loc2;
            }
            ObjCreate.createBg(10, 30, 435, 2, this, ImagesConst.SplitLine);
            this._infoPanel = new GuildActivityInfoPanel();
            this._infoPanel.x = 452;
            this.addChild(this._infoPanel);
            this._activityList = new TilePanel();
            this._activityList.setSize(440, 370);
            this._activityList.columnWidth = 430;
            this._activityList.rowHeight = 41;
            this._activityList.verticalGap = 0;
            this._activityList.setStyle("cellRenderer", GuildActivityCellRenderer);
            this._activityList.move(10, 30);
            this._activityList.addEventListener(ListEvent.ITEM_CLICK, this.onListClickHandler);
            this.addChild(this._activityList);
            return;
        }

        public initData(): void
        {
            this.updateDataProvider(GuildActivityConfig.instance.activitys);
            this._activityList.selectedIndex = 0;
            this._configInfo = this._activityList.selectedItem as GuildActivityConfigInfo;
            this._infoPanel.updateByGuildActivityConfigInfo(this._configInfo);
            return;
        }

        /* internal  */updateDataProvider(arg1: Array<any>): void
        {
            if (this._dataProvider) 
            {
                this._dataProvider.removeAll();
            }
            else 
            {
                this._dataProvider = new DataProvider();
            }
            var loc1=0;
            while (loc1 < arg1.length) 
            {
                this._dataProvider.addItem(arg1[loc1]);
                ++loc1;
            }
            this._activityList.dataProvider = this._dataProvider;
            return;
        }

        /* internal  */onListClickHandler(arg1: ListEvent): void
        {
            this._configInfo = arg1.item as GuildActivityConfigInfo;
            this._infoPanel.updateByGuildActivityConfigInfo(this._configInfo);
            return;
        }

        /* internal */ /* var */_titleTxt1: Object /* flash.text.TextField */;

        /* internal */ /* var */_descTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_titleTxt2: Object /* flash.text.TextField */;

        /* internal */ /* var */_activityList: TilePanel;

        /* internal */ /* var */_infoPanel: GuildActivityInfoPanel;

        /* internal */ /* var */_titleArray: Array<any>;

        /* internal */ /* var */_titleXArray: Array<any>;

        /* internal */ /* var */_dataProvider: DataProvider;

        /* internal */ /* var */_configInfo: GuildActivityConfigInfo;
    }
